//这个模块主要获取的是试题管理的数据的模块
import request from '@/utils/request'
//    /question/question/getAllQuestion获取所有题目
//    pageQuestionCondition/{current}/{limit}分页查询

//初始无条件的，使用的分页查询接口
export const reqInitQuestionList = (current, limit) => request({
    url: '/question/question/pageQuestionCondition',
    method: 'post',
    data: {
        current:current,
        limit:limit,
        name:null,
        type:null,
        major:null,
        subject:null,
        level:null,
        start:null,
        end:null,
    },
});
//没选择题库时，使用的分页查询接口
export const reqQuestionList = (current, limit,content,typeId,majorId,subjectId,levelId) => request({
    url: '/question/question/pageQuestionCondition',
    method: 'post',
    data: {
        current:current,
        limit:limit,
        name:content,
        type:typeId,
        major:majorId,
        subject:subjectId,
        level:levelId,
        start:null,
        end:null,
    },
});
//选择了题库后，使用的分页查询接口
export const reqTiKuQuestionList = (current, limit,personalQuestionStoreIds,content,typeId,majorId,subjectId,levelId) => request({
    url: '/question/personal-question-store/pagePersonalQuestionCondition',
    method: 'post',
    data: {
        personalQuestionStoreIds:personalQuestionStoreIds,
        current:current,
        limit:limit,
        name:content,
        type:typeId,
        major:majorId,
        subject:subjectId,
        level:levelId,
        start:null,
        end:null,
    },
});

//获取专业分类数据接口
export const reqGetMajorList = ()=>request({
    url:'/question/attribute/getMajorMap',
    method:'get',
});
//获取科目分类数据接口
export const reqGetSubjectList = ()=>request({
    url:'/question/attribute/getSubjectMap',
    method:'get',
});
//获取题型分类数据接口
export const reqGetTypeList = ()=>request({
    url:'/question/attribute/getTypeMap',
    method:'get',
});
//获取老师题库列表数据接口
export const reqGetQuestionKuList = ()=>request({
    url:'/question/personal-question-store/getAllPersonalQuestionStore',
    method:'get',
});

//给总题库添加一个试题
///question/question/addQuestionBody
///question/question/updateQuestion
export const reqAddOrUpdateQuestion = (question)=>{
    //判断有无id，有为修改，无为新增
    if(question.id){
        return request({
            url:'question/question/updateQuestion',
            method:'post',
            data:question,
        });
    }else{
        //新增题目
        return request({
            url:'question/question/addQuestionBody',
            method:'put',
            data:question,
        });
    }
}

//给总题库删除试题（id数组）ids
export const reqDeleteByIdsLogicQuestion = (str)=>request({
    url:'/question/question/deleteByIdsLogic',
    method:'delete',
    data:str,
});

//添加和更新个性化题库试题接口函数
//添加试题到个性化题库
///question/personal-question-store/addQuestionToPersonalQuestionStore
//@RequestBody PersonalQuestion personalQuestion, String[] personalQuestionStoreIds
//更新试题到个性化题库
///question/personal-question-store/updatePersonalQuestion
//@RequestBody PersonalQuestion personalQuestion
export const reqAddOrUpdateQuestionPersonal = (question,personalQuestionStoreIds)=>{
    //判断有无id，有为修改，无为新增
    if(question.id){
        return request({
            url:'/question/personal-question-store/updatePersonalQuestion',
            method:'post',
            data:question,
        });
    }else{
        //新增题目
        return request({
            url:'/question/personal-question-store/addQuestionToPersonalQuestionStore',
            method:'post',
            data:question,
            params:{personalQuestionStoreIds},
        });
    }
}

// 逻辑删除多个个人题目
// /question/personal-question-store/deletePersonalQuestionByIdsLogic
// String[] personalQuestionIds
export const reqDeletePersonalQuestionByIdsLogic = (str)=>request({
    url:'/question/personal-question-store/deletePersonalQuestionByIdsLogic',
    method:'post',
    data:str,
});

//把总题库试题，添加到个性化题库里
// /question/personal-question-store/addQuestionToPersonalStore
// @param questionIds              总题库试题id组
// @param personalQuestionStoreIds 老师个人题库id组
export const reqAddQuestionToPersonalStore = (str)=>request({
    url:'/question/personal-question-store/addQuestionToPersonalStore',
    method:'post',
    data:str,
});